{include file="./layout/header.html" /}
<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:left" onClick="javaScript:history.go(-1)" title="返回">
        <i class="layui-icon" style="line-height:30px">&#xe65c;</i></a>

    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" >
    <form class="layui-form" id="intr">

        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input   type="hidden" id="sid" name="sid" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value='{$sid}'>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="code" class="layui-form-label">
                <span class="x-red">*</span>父级
            </label>
            <div class="layui-input-inline">
                <!--<input   type="text" id="parent_id" name="parent_id" required="" lay-verify="required"-->
                         <!--autocomplete="off" class="layui-input" placeholder="" value="ROOT">-->
                <select id="parent_id" name="parent_id" lay-verify="">
                    <option value="">请选择层级</option>
                    <option value="ROOT">无</option>
                    {foreach $intr as $key => $vo}
                        {if condition="$vo->parent eq 'ROOT'"}
                            <option value="{$vo->uid}">{$vo->url}</option>
                        {/if}
                    {/foreach}
                </select>
            </div><span style="line-height: 37px"></span>
        </div>

        <div class="layui-form-item">
            <label for="code" class="layui-form-label">
                <span class="x-red">*</span>URL
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="url" name="url" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="请输入url地址" value="">
            </div><span style="line-height: 37px">显示在地址栏中的url,如about</span>
        </div>

        <div class="layui-form-item">
            <label for="code" class="layui-form-label">
                <span class="x-red">*</span>链接模块
            </label>
            <div class="layui-input-inline">
                <!--<input   type="text" id="code" name="module" required="" lay-verify="required"-->
                         <!--autocomplete="off" class="layui-input" placeholder="请输入模块名称" value="PAGE">-->
                <select id="module" name="module" lay-verify="">
                    <option value="">请选择模块</option>
                    <option value="PAGE">单页</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="code" class="layui-form-label">
                <span class="x-red">*</span>菜单位置
            </label>
            <div class="layui-input-inline">
                <!--<input   type="text" id="code" name="position" required="" lay-verify="required"-->
                         <!--autocomplete="off" class="layui-input" placeholder="请输入位置名称" value="MAIN">-->
                <select id="position" name="position" lay-verify="">
                    <option value="">请选择位置</option>
                    <option value="MAIN">主菜单</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="target_id" class="layui-form-label">
                <span class="x-red">*</span>链接目标
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="target_id" name="target_id" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="请选择目标">
                <!--<select id="target_id" name="target_id" lay-verify="">-->
                    <!--<option value="">请选择目标</option>-->
                    <!--<option value="LIST">列表</option>-->
                    <!--<option value="Ry">1</option>-->
                    <!--<option value="MAIN">2</option>-->
                <!--</select>-->
            </div>
            <a class="layui-btn" onclick="x_admin_show('选择','{:url("Confermenu/target")}?sid={$sid}')">选择目标</a>
        </div>

        {foreach $lang.hy as $vo}
        <div class="layui-form-item">
            <label for="['{$vo.lan}']['title']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.title}
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][name]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="站点菜单">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="['{$vo.lan}']['content']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.content}
            </label>
            <div class="layui-input-block">
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['content']" name="translations[{$vo.lan}][description]" class="layui-textarea"></textarea>
            </div>
        </div>
        {if condition="$vo.lan eq 'en'"}
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor("['en']['content']");
        </script>
        {else/}
        <script type="text/javascript">
            var ue = UE.getEditor("['zh-CN']['content']");
        </script>
        {/if}
        {/foreach}

        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                增加
            </button>
        </div>


    </form>
</div>


<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            // var str = new Array(); //定义一数组
            // str = uri$('#intr').serialize();
            var formData = $("#intr").serialize();

            //发异步，把数据提交给php
            $.ajax({
                dataType : 'json',
                type : 'POST',
                url : '{:url("Confermenu/add")}',
                async: false,
                data : formData,
                success : function(msg){
                    layer.alert(msg.msg, {icon: 6},function () {
                        window.history.go(-1);
                        // window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);

                    });
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status + "," + textStatus);
                }
            });

            return false;
        });


    });


</script>
{include file="./layout/footer.html" /}